
function main(){
    alert("Run!");
    return "This is back!";
}


function ImportAep(path,compositionName){   
    var cur = app.project.activeItem;  
    var AnimationFolder = SearchFolder(); 
        try{
            var file = File(path);
            var io = new ImportOptions(file);
            var childFolder = app.project.importFile(io);
            childFolder.parentFolder = AnimationFolder;
            if(cur){
                for(var i=0; i<app.project.numItems; i++){
                    if(app.project.items[i+1].name == compositionName&&app.project.items[i+1].typeName == '合成'||app.project.items[i+1].typeName =='Composition'){
                        var comp = app.project.items[i+1];
                        var newLayer = cur.layers.add(comp);
                        newLayer.startTime = cur.time;
                        break;
                    }
                }
            }
        }catch(err){
            alert(err);
        }      
}


function SearchFolder(){
    var AnimationFolder = null;
    for(var i=0; i<app.project.numItems; i++){
        if(app.project.items[i+1].name == 'Animation'){
            AnimationFolder = app.project.items[i+1];
            return AnimationFolder;
        }
    }

    if(AnimationFolder == null){
        AnimationFolder = app.project.items.addFolder('Animation');
        return AnimationFolder;
    }
}